﻿<!DOCTYPE html>
<html>
<!-- 课件管理-编辑 -->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>

</head>

<body>
    <div id="app" class="popupW50" v-cloak>
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
                 size="mini">
            <el-row>
                <!--课题名称-->
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item prop="topicname">
                            <el-input type="text" v-model="Form.topicname" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Coursewaremanagement.Topicname+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="Form.topicname.length<=0">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>

                        </el-form-item>
                    </div>
                </el-col>
                <!--培训方式-->
                <!--<el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item  prop="trainingmode">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{Coursewaremanagement.Trainingmode+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.trainingmode" slot="suffix"
                                               :placeholder="Coursewaremanagement.Trainingmode">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in TrainingmodeL" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>-->

                <!--开始时间-->
                <el-col :span="11" >
                    <el-form-item prop="trainingdate">
                        <div class="elst-select-mini" style="margin-left: -0px">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{Coursewaremanagement.Trainingdate+mark.m}}
                                </template>
                                <el-date-picker slot="suffix" v-model="Form.trainingdate" type="date" size="mini"
                                                format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择时间">
                                </el-date-picker>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.trainingdate">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </div>
                    </el-form-item>
                </el-col>

                <!--结束时间-->
                <el-col :span="11" offset="2">
                    <el-form-item prop="endtim">
                        <div class="elst-select-mini" style="margin-left: -0px">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{Coursewaremanagement.Endtime+mark.m}}
                                </template>
                                <el-date-picker slot="suffix" v-model="Form.endtim" type="date" size="mini"
                                                format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择时间">
                                </el-date-picker>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.endtim">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </div>
                    </el-form-item>
                </el-col>

                <el-col :span="20">
                    <div class="elst-select-mini">
                         <div class="elst-select-mini">
                        <!--<el-form-item prop="attachment">

                            <label for="Trainingtime" class="el-form-item__label"
                                   style="width: 150px;">{{Coursewaremanagement.Courseware+mark.m}}</label>

                            <span>
                                <btn-uploadfile-input  v-model="Form.attachmentName" text="导入课件"
                                                      :fileid="Form.attachment" :filename="Form.attachmentName" :showdownload="true"
                                                      @success="attachmentHandle"></btn-uploadfile-input>
                              
                            </span>
                        </el-form-item>-->

                        <el-form-item prop="courseAttachment">

                            <label for="Trainingtime" class="el-form-item__label"
                                   style="width: 100px;">{{Coursewaremanagement.Courseware+mark.m}}</label>

                        <span>
                            <btn-uploadfile-input-kj v-loading.fullscreen.lock="fullscreenLoading" 
                         v-model="Form.attachmentName" text="导入课件" :fileid="Form.courseAttachment" ref="upbtn" :filename="Form.attachmentName" :showdownload="true" @changelodding="changelodding" @success="attachmentHandle"></btn-uploadfile-input-kj>
                        </span>
                        <span class="iputLineMust" v-if="!Form.attachmentName">
                            <!-- 必填项添加 -->
                            <img src="/static/images/exclamation.png" alt="">
                        </span>
                    </el-form-item>


                    </div>
                        <!--<el-form-item>
                            <el-input disabled type="text" v-model="Form.Courseware" autocomplete="off" size="mini" readonly>
                                <template slot="prepend">
                                    {{Coursewaremanagement.Courseware+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>-->
                    </div>
                </el-col>
                <el-col :span="4">
                    <!--<el-upload ref="Attachmentupload" action="/api/File/UpdateFile" multiple="true"
                               :on-preview="handlePreview" :on-remove="handleRemove"
                               :before-upload="CoursewareUploadbeforeupload" :auto-upload="true" :limit="1"
                               :show-file-list="false">
                        <el-button class="ml10" type="primary" size="mini" @click="btnAttachmentUpload">
                            {{col.btnImportcourseware}}
                        </el-button>
                    </el-upload>-->
                </el-col>
                <el-col :span="20">
                      
                    <!--<div class="elst-select-mini">
                        <el-form-item>
                            <el-input disabled type="text" v-model="Form.testquestions" autocomplete="off" size="mini" readonly>
                                <template slot="prepend">
                                    {{Coursewaremanagement.testquestions+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>-->
                </el-col>
                <el-col :span="4">
                    <!--<el-upload ref="Attachmentupload" action="/api/File/UpdateFile" multiple="true"
                               :on-preview="handlePreview" :on-remove="handleRemove"
                               :before-upload="testquestionsUploadbeforeupload" :auto-upload="true" :limit="1"
                               :show-file-list="false">
                        <el-button class="ml10" type="primary" size="mini" @click="btnAttachmentUpload">
                            {{col.btnImporttestquestions}}
                        </el-button>
                    </el-upload>-->
                </el-col>
            </el-row>
          
            <br>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>-->
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
       
    </div>
    <script type="text/javascript">
        var uploadText = "请选择上传文件";
        var app = new Vue({
            el: '#app',
            data: {
                pageInitial: null,
                fullscreenLoading: false,
                //父业传参
                id: '',
                value1: '',
                //获取下拉菜单
                TrainingmodeL: [],
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    topicname: '',
                    //trainingmode: '',
                    trainingdate: '',
                    endtim: '',
                    Courseware: uploadText,
                    testquestions: uploadText,
                    attachment: '',
                    attachmentName: '',
                    courseAttachment:'',
                },
                //表单验证
                rules: {
                     topicname: [
                         verification.NotNull
                     ],
                     //trainingmode: [
                     //    verification.NotNullSelect
                     //],
                     trainingdate: [
                         verification.NotNull
                     ],
                     endtim: [
                         verification.NotNull
                     ],
                    // Qualifiedscore: [
                    //     verification.NotNull
                    // ],
                    // Scoreperitem: [
                    //     verification.NotNull
                    // ],
                    // Trainingobjectives: [
                    //     verification.NotNull
                    // ],
                    // Trainingmode: [
                    //     verification.NotNull
                    // ]
                    courseAttachment: [
                        verification.NotNull

                    ],
                }
            },
            methods: {
                changelodding: function (val) {
                    this.fullscreenLoading = val;
                },
                //上传附件文件的校验
                CoursewareUploadbeforeupload: function (file) {
                    var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
                    //将附件名赋值到label上
                    this.Form.Courseware = file.name;
                    const extension = testmsg === 'doc'
                    const extension2 = testmsg === 'pdf'
                    const isLt10M = file.size / 1024 / 1024 < 10
                    if (!extension && !extension2) {
                        this.$message({
                            message: '上传文件只能是 doc、pdf格式!',
                            type: 'warning'
                        });
                    }
                    if (!isLt10M) {
                        this.$message({
                            message: '上传文件大小不能超过 10MB!',
                            type: 'warning'
                        });
                    }
                    if (extension || extension2 && isLt10M)
                        submitUpload(this, 'upload')
                    return extension || extension2 && isLt10M
                },
                btnAttachmentUpload: function () {
                    //若更换文件则将文件名字更换触发条件--先删除上一个文件,后添加一个文件
                    if (this.fileAttachmentUpload != uploadText) {
                        this.$refs.Attachmentupload.clearFiles();
                        this.fileAttachmentUpload = file.name;
                    }
                    else {

                    }
                    this.$refs.Attachmentupload.submit();
                },
                attachmentHandle: function (response, fileid, fileName, htmlid, b) {
                    debugger;
                    this.Form.courseAttachment = fileid;
                    this.Form.attachmentName = fileName;
                    this.Form.htmlID = htmlid;
                    if (b) {
                        this.fullscreenLoading = false;

                    }

                },
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleRemove: function (file) {
                    console.log(file);
                },
                handlePreview: function (file) {
                    console.log(file.name);
                    window.open(file.url)
                },
               
                //查询方法
                onSubmit: function () { onSubmit(this); },
                btnUpLoad: function () {
                    this.$message({
                        message: '上传成功',
                        type: 'success'
                    });
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/ZB_Course/Save', mythis.Form);
                        } else {
                            //验证失败
                            return false;
                        }
                    });
                },
                getData: function () {
                    getData(this, '/api/ZB_Course/get?id=' + this.id);
                },
                //attachmentHandle: function (response, fileid, fileName) {

                //    //console.log('fileid', fileid)
                //    //console.log('fileName', fileName)

                //    this.Form.attachment = fileid;
                //    this.Form.attachmentName = fileName;

                //    //console.log(' this.Form.attachment', this.Form.attachment)
                //    //console.log(' this.Form.attachmentName', this.Form.attachmentName)

                //},
              
            },
            mounted: function () {
                //初始化数据
                //列表高度自适应
                tablehigh(this);
                this.id = getUrlParam("id");
                this.getData();
                //获取下拉菜单内容
                this.pageInitial = PageInitial(['zbkjglpxfs']);//培训方式 初始化
                var dicDataList = this.pageInitial.dataDicList;
                this.TrainingmodeL = getDicDataFodDataList(dicDataList, 'zbkjglpxfs');//培训方式
            }

        });
    </script>
</body>

</html>